<template class="content">
    <div :class="['message', message.sender]">
        <p>{{ message.text }}</p>
    </div>
</template>

<script lang="ts">
export default {
  props: {
    message: {
      type: Object,
      required: true,
    },
  },
};
</script>

<style scoped>
.content {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.message {
    margin: 5px 0;
    padding: 0 10px;
    border-radius: 12px;
    max-width: 70%;
    width: fit-content;
    /* 关键修改 */
    word-wrap: break-word;
    white-space: pre-wrap;
    transition: all 0.3s ease;
    background-color: #474747;
    color: white;
}

.message p {
    display: inline-block;
    /* 使p元素根据内容宽度自适应 */
    max-width: 100%;
    /* 确保内容不会超出父容器 */
    word-wrap: break-word;
    /* 保证长文本自动换行 */
}


.message.User {
    text-align: left;
    background-color: #2d7ff9;
    max-width: 90%;
    margin-left: auto;
}

.message.Claude {
    text-align: left;
    background-color: #333;
    max-width: 90%;
    margin-right: auto;
}
</style>